//
//  BaseNavigationBar.m
//  DailyRecord
//
//  Created by Gin on 2022/4/16.
//

#import "BaseNavigationBar.h"

@interface BaseNavigationBar ()

@property (nonatomic, strong) UILabel *titleLb;

@property (nonatomic, strong, readwrite) UIButton *backBtn;

@end

@implementation BaseNavigationBar

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kColorWithHex(0xe6e6e6, 0.5);
    }
    return self;
}

- (void)initUI{
    [self addSubview:self.titleLb];
    [self addSubview:self.backBtn];
}

- (void)setUpContraints{
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self.mas_bottom).offset(-kBottomSpace);
    }];
    
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kLeftSpace);
        make.size.mas_equalTo(CGSizeMake(kSmallButtonHeight, kSmallButtonHeight));
        make.bottom.equalTo(self.titleLb.mas_bottom).offset(5);
    }];
}

- (void)setTitle:(NSString *)title{
    self.titleLb.text = title;
}

#pragma mark -- setter&&getter

- (UILabel *)titleLb{
    if (!_titleLb) {
        _titleLb = [UILabel new];
        _titleLb.font = kTitleFont;
    }
    return _titleLb;
}

- (UIButton *)backBtn{
    if (!_backBtn) {
        _backBtn = [UIButton new];
        [_backBtn setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
        [_backBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
        _backBtn.hidden = YES;
    }
    return _backBtn;
}


@end
